package com.agent.membership.api.feign;

import com.agent.common.result.ApiResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 积分Feign客户端
 * @author Jeff_Wan
 * @description 提供积分服务的远程调用接口
 */
@FeignClient(name = "agent-membership", contextId = "credit", path = "/api/credits")
public interface CreditFeignClient {

    /**
     * 获取用户剩余积分
     * @param userId 用户ID
     * @return 剩余积分
     */
    @GetMapping("/surplus/{userId}")
    ApiResponse<Integer> getUserCredits(@PathVariable Long userId);

    /**
     * 发放订阅积分
     * @param userId 用户ID
     * @param planType 会员计划类型
     * @param subscriptionType 订阅类型
     * @return 操作结果
     */
    @PostMapping("/grant")
    ApiResponse<String> grantSubscriptionCredits(
            @RequestParam Long userId,
            @RequestParam String planType,
            @RequestParam String subscriptionType);

    /**
     * 扣除积分
     * @param userId 用户ID
     * @param credits 积分数量
     * @return 操作结果
     */
    @PostMapping("/deduct")
    ApiResponse<Void> deductCredits(@RequestParam Long userId, @RequestParam Integer credits);

    /**
     * 退还积分
     * @param userId 用户ID
     * @param credits 积分数量
     * @return 操作结果
     */
    @PostMapping("/refund")
    ApiResponse<Void> refundCredits(@RequestParam Long userId, @RequestParam Integer credits);
}